package com.example.controller;

import com.example.utils.BadRequestException;
import com.example.utils.ResultData;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.WebRequest;

@RestController
@ControllerAdvice
public class BadRequestExceptionHandle {

    @ExceptionHandler(Exception.class)
    public final ResultData<String> responseException(BadRequestException ex, WebRequest request) {
        return ResultData.fail(ex.getMessage(), request.toString());
    }
}
